<template>
  <div class="all">
    <el-row :gutter="8">
      <!-- 订单状态 -->
      <el-col :span="1.2">
        <div class="grid-content bg-purple">
          <span>订单状态</span>
        </div>
      </el-col>
      <el-col :span="2.5">
        <div class="grid-content bg-purple">
          <el-select v-model="value" placeholder="全部" class="mingcheng">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled"
            />
          </el-select>
        </div>
      </el-col>
      <!-- 订单编号 -->
      <el-col :span="1.2">
        <div class="grid-content bg-purple">
          <span>订单编号</span>
        </div>
      </el-col>
      <el-col :span="2.5">
        <div class="grid-content bg-purple">
          <el-select v-model="value" placeholder="全部" class="bianhao">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled"
            />
          </el-select>
        </div>
      </el-col>
      <!-- 订单类型 -->
      <el-col :span="1.2">
        <div class="grid-content bg-purple">
          <span>订单类型</span>
        </div>
      </el-col>
      <el-col :span="2.5">
        <div class="grid-content bg-purple">
          <el-select
            v-model="value"
            placeholder="全部"
            class="bianhao"
            style="width: 100px"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled"
            />
          </el-select>
        </div>
      </el-col>
      <!-- 支付状态 -->
      <el-col :span="1.2">
        <div class="grid-content bg-purple">
          <span>支付状态</span>
        </div>
      </el-col>
      <el-col :span="2.5">
        <div class="grid-content bg-purple">
          <el-select v-model="value" placeholder="全部" class="bianhao">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled"
            />
          </el-select>
        </div>
      </el-col>

      <el-col :span="2" :offset="3">
        <div class="grid-content bg-purple">
          <el-button class="reset">重置</el-button>
        </div>
      </el-col>
      <el-col :span="2">
        <div class="grid-content bg-purple">
          <el-button class="sure">确定</el-button>
        </div>
      </el-col>
    </el-row>
  </div>

  <el-table ref="tableRef" row-key="date" :data="tableData" style="width: 100%">
    <!-- 多选框 -->
    <el-table-column type="selection" width="40" />
    <!-- 订单编号列 -->
    <el-table-column
      prop="goodsId"
      label="订单编号"
      width="150"
      column-key="date"
    />
    <!-- 实付金额列 -->
    <el-table-column prop="actualMoney" label="实付金额" width="100" />
    <!-- 快递金额列 -->
    <el-table-column prop="courierMoney" label="快递金额" width="100" />
    <!--收货人列 -->
    <el-table-column prop="name" label="收货人" width="100" />
    <!-- 收货地址列 -->
    <el-table-column
      prop="goodsAddress"
      label="收货地址"
      :formatter="formatter"
      width="300"
    />
    <!-- 支付方式列-->
    <el-table-column prop="methodPay" label="支付方式" width="100" />
    <!-- 状态列 -->
    <el-table-column prop="tag" label="订单状态" width="100">
      <template #default="scope">
        <el-tag
          :type="scope.row.tag === 'Home' ? '' : 'success'"
          disable-transitions
          >{{ scope.row.tag }}</el-tag
        >
      </template>
    </el-table-column>
    <!-- 操作列 -->
    <el-table-column
      prop="operation"
      label="操作"
      width="210"
      style="margin: 0 auto"
    >
      <template #default="scope">
        <el-button size="small" @click="handleEdit(scope.$index, scope.row)">
          修改
        </el-button>
        <el-button size="small" @click="handleDelete(scope.$index, scope.row)">
          删除
        </el-button>
        <el-button size="small" @click="handleDelete(scope.$index, scope.row)">
          确定
        </el-button>
      </template>
    </el-table-column>
  </el-table>
  <!-- 分页 -->
  <div class="page">
    <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="size"
      @next-click="next"
      @prev-click="prev"
      @current-change="current"
    />
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
// import { useRouter } from "vue-router";
import dataProduct from "../../../mock/dataProduct";

const tableData = ref([]);
const size = ref(11);
const page = ref(1);
const total = ref();
onMounted(async () => {
  const res = await dataProduct.getData({ page: page.value, size: size.value });
  if (res.status === 0) {
    tableData.value = [...res.result];
    total.value = res.count;
  }
});
// 分页
const current = async (val) => {
  page.value = val;
  const res = await dataProduct.getData({ page: page.value, size: size.value });
  if (res.status === 0) {
    tableData.value = [...res.result];
    total.value = res.count;
  }
};
const next = async (val) => {
  page.value = val;
  const res = await dataProduct.getData({ page: page.value, size: size.value });
  if (res.status === 0) {
    tableData.value = [...res.result];
    total.value = res.count;
  }
};
const prev = async (val) => {
  page.value = val;

  const res = await dataProduct.getData({ page: page.value, size: size.value });
  if (res.status === 0) {
    tableData.value = [...res.result];
    total.value = res.count;
  }
};
</script>

<style lang="less" scoped>
.all {
  .el-row {
    margin-bottom: 20px;
  }
  .el-row:last-child {
    margin-bottom: 0;
  }
  .el-col {
    border-radius: 4px;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  span {
    width: 71px;
    height: 18px;
    font-size: 16px;
    line-height: 36px;
    font-family: MicrosoftYaHei;
    font-weight: bold;
    color: #333333;
    margin-right: 11px;
  }
  :deep(.mingcheng) {
    .el-input__wrapper {
      max-width: 100px;
      height: 38px;
      border: 2px solid #cccccc;
    }
    .el-input__inner::placeholder {
      width: 36px;
      height: 18px;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      font-weight: bold;
      color: #333333;
    }
  }
  :deep(.bianhao) {
    .el-input__wrapper {
      max-width: 120px;
      height: 38px;
      border: 2px solid #cccccc;
    }
    .el-input__inner::placeholder {
      width: 36px;
      height: 18px;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      font-weight: bold;
      color: #333333;
    }
  }
  .add {
    width: 100%;
    height: 38px;
    background: #fcc284;
    font-weight: bold;
    color: #333333;
  }
  .remove {
    width: 100%;
    height: 38px;
    border: 2px solid #cccccc;
    font-weight: bold;
    color: #333333;
  }
  .reset {
    width: 100%;
    height: 38px;
    border: 2px solid #cccccc;
    font-weight: bold;
    color: #333333;
  }
  .sure {
    width: 100%;
    height: 38px;
    background: #fcc284;
    font-weight: bold;
    color: #333333;
  }
}
.page {
  width: 81.5%;
  height: 20px;
  // background-color: yellow;
  position: fixed;
  right: -25%;
  bottom: 20px;
}
</style>
